package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.hz.Messageconfiguration;
import com.example.entity.hz.Messagetype;
import com.example.service.MessagetypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@CrossOrigin // 跨域
@RestController
@RequestMapping("/api/MessageType")
@Api(tags = "消息模块配置前端控制器")
public class MessageTypeController {

    @Resource
    private MessagetypeService messagetypeService;

    @ApiOperation("消息模块新增 批量或单独")
    @PostMapping("/insertMessageType")
    public Result insertMessageType(@RequestBody List<Messagetype> messagetypeList){
        return this.messagetypeService.insertMessageType(messagetypeList);
    }

    @ApiOperation("消息模块通过主键uuid进行删除")
    @PostMapping("/deleteMessageType")
    public Result deleteMessageType(@RequestBody List<Integer> uuidList){
        return this.messagetypeService.deleteMessageType(uuidList);
    }

    @ApiOperation("消息模块分页查询")
    @PostMapping("/queryMessageTypePage/{current}/{size}")
    public Result<Map<String, Messagetype>> queryMessageTypePage(@PathVariable Integer current, @PathVariable Integer size){
        return this.messagetypeService.queryMessageTypePage(current,size);
    }

    @ApiOperation("消息模块List查询,并且获取消息模版信息")
    @PostMapping("/queryMessageTypeList")
    public Result<List<Messagetype>> queryMessageTypeList(){
        return this.messagetypeService.queryMessageTypeList();
    }

    @ApiOperation("通过uuid查询到绑定的消息通知模版")
    @GetMapping("/queryMessageConfigurationList/{uuid}")
    public Result<List<Messageconfiguration>> queryMessageConfigurationList(@PathVariable Integer uuid){
        return this.messagetypeService.queryMessageConfigurationList(uuid);
    }

    @ApiOperation("通过主键uuid查询到消息模块的详情信息")
    @GetMapping("/queryOneMessageType/{uuid}")
    public Result<Messagetype> queryOneMessageType(@PathVariable Integer uuid){
        return this.messagetypeService.queryOneMessageType(uuid);
    }

    @ApiOperation("修改消息模块")
    @PostMapping("/updateMessageType")
    public Result updateMessageType(@RequestBody Messagetype messagetype){
        return this.messagetypeService.updateMessageType(messagetype);
    }
}
